import React, { Component } from 'react'
import Child5 from '../component/Child5';
import Child6 from '../component/Child6';
export default class CTP extends Component {
    constructor(props){
        super(props);
        this.state={
            num:""
        }
    }
    add=(n)=>{
        this.setState({
            num:n
        })
    }
    aff=()=>{
        this.setState({
            num:this.refs.child6.refs.name.value
        })
    }
  render() {
    return (
      <div>
          <div>父组件接收的值是：{this.state.num}<button onClick={this.aff}>点击索取子组件2的值</button></div>
          <hr></hr>
          <Child5 add={this.add}></Child5>
          <Child6 add={this.add} ref="child6"></Child6>
      </div>
    )
  }
}
